//
//  MovSendTableViewCell.m
//  电影er
//
//  Created by dllo on 16/6/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MovSendTableViewCell.h"
#import "MoviesModol.h"
#define Hig self.contentView.frame.size.height
#define Wih self.contentView.frame.size.width
@interface MovSendTableViewCell()

@property(nonatomic,retain)UILabel *label1;
@property(nonatomic,retain)UILabel *label2;
@property(nonatomic,retain)UILabel *label3;
@property(nonatomic,retain)UILabel *label4;
@property(nonatomic,retain)UILabel *label5;
@property(nonatomic,retain)UILabel *label6;
@property(nonatomic,retain)UILabel *label7;
@property(nonatomic,retain)UILabel *label8;
@property(nonatomic,retain)UILabel *label9;
@property(nonatomic,retain)UILabel *label10;
@property(nonatomic,retain)UILabel *label11;
@property (nonatomic,retain)UILabel *titleLabel;
@property(nonatomic,retain)UILabel *plotLabel;//影片简介;
@property(nonatomic,retain)UIImageView *imageview;

@property (nonatomic,retain)NSMutableArray *muarray;

@end

@implementation MovSendTableViewCell
-(void)dealloc{

    [_muarray release];
    [_label1 release];
    [_label2 release];
    [_label3 release];
    [_label4 release];
    [_label5 release];
    [_label6 release];
    [_label7 release];
     [_label8 release];
     [_label9 release];
     [_label10 release];
    [_label11 release];
    [_titleLabel release];
    [_imageview release];
    [super dealloc];
    
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.muarray = [[NSMutableArray alloc]init];
        self.label1 = [[UILabel alloc]init];
        self.label1.text = @"评分";
        self.label1.frame = CGRectMake(200,50, 100, 30);
        [self.contentView addSubview:self.label1];
        [self.label1 release];
        self.label2 = [[UILabel alloc]init];
        self.label2.text = @"制作人";
        self.label2.font =[UIFont boldSystemFontOfSize:30];
        self.label2.frame = CGRectMake(20, 280, 100, 50);
          [self.contentView addSubview:self.label2];
        [self.label2 release];
        self.label3 = [[UILabel alloc]init];
        self.label3.text = @"电影情节";
        self.label3.font = [UIFont boldSystemFontOfSize:30];
        self.label3.frame = CGRectMake(20,380,200,50);
        [self.contentView addSubview:self.label3];
        [self.label3 release];
        self.label4 =[[UILabel alloc]init];
        [self.contentView addSubview:self.label4];
        
        self.label5 =[[UILabel alloc]init];
        [self.contentView addSubview:self.label5];
        [self.label5 release];
        self.label6 =[[UILabel alloc]init];
        [self.contentView addSubview:self.label6];
        [self.label6 release];
        self.label7 =[[UILabel alloc]init];
        [self.contentView addSubview:self.label7];
        [self.label7 release];
        self.label8 =[[UILabel alloc]init];
        [self.contentView addSubview:self.label8];
        [self.label8 release];
        self.label9 =[[UILabel alloc]init];
        [self.contentView addSubview:self.label9];
        [self.label9 release];
        self.label10 =[[UILabel alloc]init];
        [self.contentView addSubview:self.label10];
        [self.label10 release];
        self.label11 =[[UILabel alloc]init];

        [self.contentView addSubview:self.label11];
        self.titleLabel = [[UILabel alloc]init];
        [self.label11 release];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        self.plotLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_plotLabel];
        [_plotLabel release];
        self.imageview = [[UIImageView alloc]init];
        [self.contentView addSubview:_imageview];
        [_imageview release];
        
    }
    return self;
    
}
-(void)layoutSubviews{
    [super layoutSubviews ];

//    self.titleLabel.frame = CGRectMake(100, 10, 500, 200);
    self.plotLabel.frame = CGRectMake(20,410,380,400);
    self.plotLabel.numberOfLines = 0;
    self.label4.frame = CGRectMake(280, 50, 100,30);
//    self.label5.frame = CGRectMake(20, 10, 100, 50);
    self.label6.frame = CGRectMake(200, 200, 200, 50);
    self.label7.frame = CGRectMake(200, 220, 100, 50);
    
    self.label8.frame = CGRectMake(20, 250, 350, 200);

    self.label8.numberOfLines = 0;
    self.label9.frame = CGRectMake(240, 50, 100, 30);
    self.label10.frame = CGRectMake(200, 100, 100, 50);
    self.label11.frame = CGRectMake(200, 150, 100, 50);

    
}
-(void)setMovModol:(MoviesModol *)movModol{
    if (_movModol != movModol) {
        [_movModol release];
        _movModol = [movModol retain];
        
    }
//    self.titleLabel.text = movModol.movieName;
    NSString *str = [[NSBundle mainBundle]pathForResource:[NSString stringWithFormat:@"m%@",self.movModol.movieId]ofType:@".txt"];
    NSData *data= [NSData dataWithContentsOfFile:str];
    NSError *error = nil;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
    NSDictionary *array = [dic objectForKey:@"result"];
    [movModol setValuesForKeysWithDictionary:array];
    [self.muarray addObject:movModol];
    self.plotLabel.text = movModol.plot_simple;//情节
    self.label4.text =   [NSString  stringWithFormat:@"%@评论",movModol.rating_count];//评论
//    self.label5.text = movModol.year;//年份
    self.label6.text = movModol.genres;//类型
    self.label7.text = movModol.country;//制作地区
    self.label8.text = movModol.actors;//制作人
    self.label9.text = movModol.rating;//评分
    self.label10.text = movModol.release_date;//上映时间
    self.label11.text = movModol.runtime;//时长

    NSURL *url = [NSURL URLWithString:movModol.poster];
    NSData *data1 = [NSData dataWithContentsOfURL:url];
    self.imageview.frame = CGRectMake(10, 10, 180, 250);
    self.imageview.image = [UIImage imageWithData:data1];
    
    
    

}











@end
